package com.examination.mlib.dialog.dialog;

import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.examination.mlib.R;
import com.yilijk.base.basedialog.BaseDialog;
import com.yilijk.base.basedialog.DialogChain;
import com.yilijk.base.utils.ClickUtils;

/**
 * Created by SHICHENG
 * <未提交就诊人信息提示>
 * Time on 2022/03/01
 *
 *
 */
public class InquiryDialog extends BaseDialog implements View.OnClickListener {

    private TextView messageSignTitle;
    private TextView messageSignContent;
    private TextView messageSignButton;
    private ImageView messageSignClose;
    private ClickListener listener;

    public InquiryDialog(@NonNull Context context) {
        super(context);
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_inquiry);

        messageSignTitle = (TextView) findViewById(R.id.message_sign_title);
        messageSignContent = (TextView) findViewById(R.id.message_sign_content);
        messageSignButton = (TextView) findViewById(R.id.message_sign_button);
        messageSignClose = (ImageView) findViewById(R.id.message_sign_close);

        ClickUtils.setFastOnClickListener(messageSignClose, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                if (listener!=null){
                    listener.close();
                }
            }
        });

        ClickUtils.setFastOnClickListener(messageSignButton, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
               if (listener!=null){
                   listener.go();
                   dismiss();
               }
            }
        });


    }

    @Override
    public void onClick(View v) {

    }

    @Override
    public void show() {
        super.show();
        if (messageSignContent!=null){
            messageSignContent.setText(remindContent);
        }
    }

    @Override
    public void intercept(@NonNull DialogChain chain) {
        if (chain != null){
            super.intercept(chain);
        }
    }

    public void setMessageSignTitle(String title){
        if (messageSignTitle!=null){
            messageSignTitle.setText(title);
        }
    }

    private String remindContent;
    public void setMessageSignContent(String content) {
        this.remindContent = content;
    }

    public void setListener(ClickListener listener) {
        this.listener = listener;
    }

    public interface ClickListener{
        void go();
        void close();
    }
}
